package primary.dynamic_programming;

/**
 * @Author Elephas
 * @Date 2022/1/8
 **/
public class MaxProfit {
    public int maxProfit(int[] prices){
        int sum = 0, max = 0;
        for (int i = 0; i < prices.length; i++) {
            sum += prices[i];
            if(sum<0){
                sum = 0;
            }
            if(sum > max){
                max = sum;
            }
        }
        return max;
    }
}
